package com.syl.starter.itools.common.enums;

import com.syl.starter.itools.base.constants.DateConstant;
import com.syl.starter.itools.base.constants.RegexConstant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 *  
 * h | value
 * - | -
 * FULL_CN_DATE | yyyy-MM-dd HH:mm:ss
 * SIMPLE_CN_DATE | yyyy-MM-dd
 *
 * @author syl
 * @create 2019-04-02
 *
 **/
@Getter
@AllArgsConstructor
public enum DateVerifyFormatEnum{
    FULL_CN_DATE(DateConstant.DATE_TIME_NORMAL, RegexConstant.DATE_4Y2M2D2H2M2S),
    SIMPLE_CN_DATE(DateConstant.DATE_NORMAL, RegexConstant.DATE_4Y2M2D),
    NULL(null, null),
    ;

    private String format;
    private String regex;

    public static DateVerifyFormatEnum getEnumByFormat(String value) {
        DateVerifyFormatEnum[] values = DateVerifyFormatEnum.values();
        for (DateVerifyFormatEnum em : values) {
            if (StringUtils.equals(em.getFormat(), value))
                return em;
        }
        return NULL;
    }


}